Tawnymender12


Code/Games

Home Code/Games About me

Number Guessing

a python executable to play a number guessing game wich you can choose the difficulty of.

download


The code:


      import random

      running = True


      def game():
          print("the higher the number the harder it gets")
          difficulty = input("difficulty: ")
          answer = random.randint(1, (int(10) ** int(difficulty)))
          answer_range = int(10) ** int(difficulty)
          person_input = input("Guess my number (1-{}): ".format(answer_range))
          if str(answer) == str(person_input):
              print("That is correct")
          else:
              print("Wrong")


      while running:
          game()
          again = input("play again? (y/n) ")
          if str(again) == "y":
              continue
          elif str(again) == "n":
              running = False


      end = input("press enter to exit ")